<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="../common/head.jsp"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<script src="/js/jquery-1.8.3.min.js"></script>

<div class="right">
     <div class="location">
         <strong>你现在所在的位置是:</strong>
         <span>订单管理页面 >> 订单添加页面</span>
     </div>
    <script>
        //保存
        function baoCun(){
            var flag = false;
            var billCode = $("#billCode").val();
            var productName = $("#productName").val();
            var productUnit = $("#productUnit").val();
            var productCount = $("#productCount").val();
            var totalPrice = $("#totalPrice").val();
            var providerId = $("#providerId").val();
            var providerId = $("#providerId").val();
            if (billCode == "" ||productName == "" ||productUnit == "" || productCount == "" || totalPrice == ""){
                $("#hint").text("请完善订单信息再进行保存!")
                return false;
            }
            $.ajax({
                type:"post",//请求类型
                url:"doBillCode",//请求的url
                data:{
                    billCode:$("#billCode").val()
                }, dataType:"json",//ajax接口（请求url）返回的数据类型
                async:false,//是否位同步,true(默认值):异步false:同步
                success:function(data){//data：返回数据（json对象）
                    if (data == "1") {
                        $("#billCodeThiShi").text("此编码已存在!");
                        $("#hint").text("");
                        flag = false;
                    }else {
                        flag = true;
                    }
                },
            });
            return flag;
        }
    </script>
     <div class="providerAdd">
         <form:form modelAttribute="bill" id="billForm" name="billForm" method="post" action="doAdd" onsubmit="return baoCun()">
             <!--div的class 为error是验证错误，ok是验证成功-->
             <input type="hidden" name="method" value="add">
             <div class="">
                 <label for="billCode">订单编码：</label>
                 <input type="text" name="billCode" class="text" id="billCode" value=""> 
				 <!-- 放置提示信息 -->
				 <font color="red" id="billCodeThiShi"></font>
                 <span><form:errors path="billCode"/></span>
             </div>
             <div>
                 <label for="productName">商品名称：</label>
                 <input type="text" name="productName" id="productName" value=""> 
				 <font color="red"><form:errors path="productName"/></font>
                 <span><form:errors path="productName"/></span>
             </div>
             <div>
                 <label for="productUnit">商品单位：</label>
                 <input type="text" name="productUnit" id="productUnit" value=""> 
				 <font color="red"><form:errors path="productUnit"/></font>
                 <span><form:errors path="productUnit"/></span>
             </div>
             <div>
                 <label for="productCount">商品数量：</label>
                 <input type="text" name="productCount" id="productCount" value=""> 
				 <font color="red"></font>
             </div>
             <div>
                 <label for="totalPrice">总金额：</label>
                 <input type="text" name="totalPrice" id="totalPrice" value=""> 
				 <font color="red"></font>
             </div>
             <div>
                 <label>供应商：</label>
                 <select name="providerId" id="providerId">
                     <c:if test="${requestScope.providerList != null}">
                         <c:forEach items="${requestScope.providerList}" var="provider">
                             <option value="${provider.id}">${provider.proName}</option>
                         </c:forEach>
                     </c:if>
		         </select>
				 <font color="red"id="hint"></font>
             </div>
             <div>
                 <label >是否付款：</label>
                 <input type="radio" name="isPayment" value="1" checked="checked">未付款
                 <input type="radio" name="isPayment" value="2" >已付款
             </div>
             <div class="providerAddBtn">
                  <input type="submit" name="add" id="add" value="保存"style="line-height: 17px">
				  <input type="button" id="back" name="back" value="返回" >
             </div>
         </form:form>
     </div>
 </div>
</section>
<%@include file="../common/foot.jsp" %>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/billadd.js"></script>